/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model;

import com.agenda.model.entity.AmTbPaci;
import com.agenda.model.persistence.DAOFactory;
import com.agenda.model.repository.PacienteRepository;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ronildo
 */
@Stateless
@WebService(serviceName = "PacienteBOImpl")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
public class PacienteBOImpl implements PacienteBO {
    
    @PersistenceContext
    private EntityManager em;
    private PacienteRepository pacienteRepository;
    
    @PostConstruct
    public void initialize(){
        pacienteRepository = DAOFactory.getPacienteRepository(em);
    }
    
    @WebMethod
    public void insertPaciente(@WebParam(name = "paciente")AmTbPaci paciente){
        pacienteRepository.persist(paciente);
    }
    
    @WebMethod
    public void deletePaciente(@WebParam(name = "paciente")AmTbPaci paciente){
        pacienteRepository.remove(paciente, paciente.getNrCpf());
    }
    
    @WebMethod
    public void updatePaciente(@WebParam(name = "paciente")AmTbPaci paciente){
        pacienteRepository.update(paciente);
    }
    
    @WebMethod
    public AmTbPaci findPacienteById(@WebParam(name = "id")Long id){
        return pacienteRepository.findById(id);
    }
    
    @WebMethod
    public List<AmTbPaci> listPaciente(@WebParam(name = "paciente")AmTbPaci paciente){
        return null;
    }
}
